package com.iot.gateway.aspectj.converter;

import com.iot.gateway.annotation.FieldConverter;

/**
 * 字符串转整数转换器
 */
public class StringToIntegerConverter implements FieldConverter {

    @Override
    public Object convert(Object value) {
        try {
            if (value instanceof String) {
                return Integer.parseInt((String) value);
            }
            return Integer.parseInt(value.toString());
        } catch (NumberFormatException e) {
            throw new IllegalArgumentException("Invalid integer format");
        }
    }

}
